package org.utils.events;

import java.util.EventObject;

import org.utils.lang.ClassUtils;

public class StatusEvent extends EventObject
{
	private static final long serialVersionUID = 6677567751526999936L;
	public static final int START = 0;
	public static final int STOP = 1;
	public static final int FINISHED = STOP;
	public static final int CANCELED = 2;

	protected int status = -1;

	public StatusEvent(Object pSource, int pStatus)
	{
		super(pSource);
		status = pStatus;
	}
	/**
	 * Returns the status.
	 * @return int
	 */
	public int getStatus()
	{
		return status;
	}
	/**
	 * @see java.lang.Object#toString()
	 */
	public String toString()
	{
		String label = null;
		switch (status)
		{
			case 0 :
				label = "START";
				break;
			case 1 :
				label = "STOP | FINISHED";
				break;
			case 2 :
				label = "CANCELED";
				break;
			default :
				label = "Unknown status";
				break;
		}
		return ClassUtils.getClassName(getClass())+", status: "+label;
	}
}
